{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'CLVAP': {'LONGITUDE': -71.642993, 'LATITUDE': -33.030843}, 'CNSHK': {'LONGITUDE': 113.86305800000001, 'LATITUDE': 22.559462}, 'CNYTN': {'LONGITUDE': 114.275347, 'LATITUDE': 22.5777}, 'COBUN': {'LONGITUDE': -77.068433, 'LATITUDE': 3.875255}, 'GRPIR': {'LONGITUDE': 23.616167, 'LATITUDE': 37.971821999999996}, 'HKHKG': {'LONGITUDE': 114.13970900000001, 'LATITUDE': 22.419915}, 'LBBEY': {'LONGITUDE': 35.480692, 'LATITUDE': 33.890507}, 'MTMLA': {'LONGITUDE': 14.509457000000001, 'LATITUDE': 35.896571}, 'MYTPP': {'LONGITUDE': 103.545456, 'LATITUDE': 1.399416}, 'MXZLO': {'LONGITUDE': -104.305571, 'LATITUDE': 19.085960999999998}, 'MATNG': {'LONGITUDE': -5.8129800000000005, 'LATITUDE': 35.788207}, 'NZAKL': {'LONGITUDE': 174.78561399999998, 'LATITUDE': -36.844873}, 'PAONX': {'LONGITUDE': -79.88299, 'LATITUDE': 9.352609}, 'SGSIN': {'LONGITUDE': 103.70461999999999, 'LATITUDE': 1.3031409999999999}, 'SIKOP': {'LONGITUDE': 13.728527, 'LATITUDE': 45.537061}, 'ESALG': {'LONGITUDE': -5.444153, 'LATITUDE': 36.121949}, 'ZADUR': {'LONGITUDE': 31.050079999999998, 'LATITUDE': -29.868304}, 'FRFOS': {'LONGITUDE': 4.885655, 'LATITUDE': 43.430234000000006}, 'CNHKG': {'LONGITUDE': 114.13396999999999, 'LATITUDE': 22.315195000000003}, 'RTM': {'LONGITUDE': 4.477733, 'LATITUDE': 51.92442}, 'PAMIT': {'LONGITUDE': -79.73504399999999, 'LATITUDE': 8.616773}, 'CNSHA': {'LONGITUDE': 121.64364599999999, 'LATITUDE': 31.344022}, 'ARENA': {'LONGITUDE': -58.35677, 'LATITUDE': -34.627862}, 'PKQCT': {'LONGITUDE': 67.32748000000001, 'LATITUDE': 24.766207}, 'CAVAN': {'LONGITUDE': -123.103178, 'LATITUDE': 49.312003999999995}}\n"
     ]
    }
   ],
   "source": [
    "port_path = '../data/port.csv'\n",
    "port_data_origin = pd.read_csv(port_path)\n",
    "\n",
    "test_data_path = '../data/A_testData0531.csv'\n",
    "test_data = pd.read_csv(test_data_path) \n",
    "test_port_set = set()\n",
    "routes = test_data['TRANSPORT_TRACE'].unique()\n",
    "for route in routes:\n",
    "    ports = route.split('-')\n",
    "    test_port_set = set.union(test_port_set, set(ports))\n",
    "\n",
    "port_data = {}\n",
    "\n",
    "for item in port_data_origin.itertuples():\n",
    "    if getattr(item, 'TRANS_NODE_NAME') in test_port_set:\n",
    "        port_data[getattr(item, 'TRANS_NODE_NAME')] = {'LONGITUDE': getattr(item, 'LONGITUDE'),'LATITUDE': getattr(item, 'LATITUDE') }\n",
    "\n",
    "print (port_data)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.6 64-bit ('AI': conda)",
   "language": "python",
   "name": "python37664bitaiconda6859e03b37c34f0182c9bde8073269f7"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
